package com.hopscotch.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hopscotch.entity.Attendance;
import com.hopscotch.service.AttendanceService;
import com.hopscotch.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/attendance")
public class AttendanceController {
    @Autowired
    private AttendanceService attendanceService;

    @GetMapping("/list")
    public R list(Attendance attendance){
        PageHelper.startPage(attendance.getPageNum(),attendance.getPageSize());
        List<Attendance> list = attendanceService.list(attendance);
        PageInfo<Attendance> pageInfo = new PageInfo<>(list);
        return R.ok(pageInfo);
    }

    @GetMapping("/createtime")
    public R createTime(){
        attendanceService.createTime();
        return R.ok("打卡成功");
    }
    @GetMapping("/endtime")
    public R endTime(){
        attendanceService.endTime();
        return R.ok("签退成功");
    }
}
